package com.jianneng.jdg.model.fragment;

import com.example.com.jianneng.jdg.R;
import com.jianneng.jdg.model.homeactivity.CheckPeopleActivity;
import com.jianneng.jdg.model.homeactivity.MyCodeActivity;
import com.jianneng.jdg.model.homeactivity.MyTeamActivity;
import com.jianneng.jdg.model.homeactivity.ProjectLocationActivity;
import com.jianneng.jdg.model.homeactivity.ReportMoneyActivity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.RadioGroup.OnCheckedChangeListener;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

public class FragmentMyWork extends Fragment implements OnClickListener {
	
	private RelativeLayout mCheckPeople,mLocation,mLeves,//上下级
						mMyTeam,mReportMoney;
	private LinearLayout mChangeId,mSecondLine;//切换身份
	private View view;
	private LinearLayout mPersonCode;
	private Intent mIntent;
	private TextView mReport,mMyWork;
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		
		view=inflater.inflate(R.layout.fragment_mywork, container, false);
		return view;
	}
	
	
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		
		super.onActivityCreated(savedInstanceState);
		initView();
		
	}


	private void initView() {
		mCheckPeople=(RelativeLayout) view.findViewById(R.id.rl_mywork_checkpeople);
		mLocation=(RelativeLayout) view.findViewById(R.id.rl_mywork_location);
		mLeves=(RelativeLayout) view.findViewById(R.id.rl_mywork_lastornext);
		mMyTeam=(RelativeLayout) view.findViewById(R.id.rl_mywork_myteam);
		mReportMoney=(RelativeLayout) view.findViewById(R.id.rl_mywork_reportmoney);
		mPersonCode = (LinearLayout) view.findViewById(R.id.person_code);	
		mChangeId = (LinearLayout) view.findViewById(R.id.ly_exchangeperson);
		mReport = (TextView) view.findViewById(R.id.reportmoney_content);
		mMyWork = (TextView) view.findViewById(R.id.tv_mywork);
		mSecondLine = (LinearLayout) view.findViewById(R.id.ll_secondLine);
		mCheckPeople.setOnClickListener(this);
		mLocation.setOnClickListener(this);
		mLeves.setOnClickListener(this);
		mMyTeam.setOnClickListener(this);
		mReportMoney.setOnClickListener(this);
		mPersonCode.setOnClickListener(this);
		mChangeId.setOnClickListener(this);
		
		
	}

boolean flag_id = true;//是否是经理身份
	@Override
	public void onClick(View v) {
		switch (v.getId()) {
		case R.id.rl_mywork_checkpeople://考勤查询
			mIntent=new Intent(getActivity(),CheckPeopleActivity.class);
			startActivity(mIntent);
			break;
		case R.id.rl_mywork_reportmoney://上报工资
			mIntent=new Intent(getActivity(),ReportMoneyActivity.class);
			
			if(flag_id){//经理身份
				mIntent.putExtra("worker_id", "manager");
				
			}else{//工人身份
				mIntent.putExtra("worker_id", "worker");
				
			}
			startActivity(mIntent);
			break;
		case R.id.rl_mywork_myteam://我的团队
			mIntent=new Intent(getActivity(),MyTeamActivity.class);
			startActivity(mIntent);
			break;
		case R.id.rl_mywork_lastornext://我的上下级
			mIntent=new Intent(getActivity(),MyTeamActivity.class);
			startActivity(mIntent);
			break;
		case R.id.rl_mywork_location://项目定位
			mIntent=new Intent(getActivity(),ProjectLocationActivity.class);
			startActivity(mIntent);
			break;
		case R.id.person_code ://二维码
			mIntent = new Intent(getActivity(), MyCodeActivity.class);
			startActivity(mIntent);
			break;
		case R.id.ly_exchangeperson://切换身份
			if(flag_id){
				mReportMoney.setVisibility(View.VISIBLE);
				mReport.setText("我的工资");
				mLeves.setVisibility(View.GONE);
				mSecondLine.setVisibility(View.GONE);
				mMyWork.setText("我的工作-员工");
				Toast.makeText(getActivity(), "worker", 1).show();
				flag_id=false;
			}else{
				mReport.setText("上报工资");
				mLeves.setVisibility(View.VISIBLE);
				mMyWork.setText("我的工作-经理");
				mSecondLine.setVisibility(View.VISIBLE);
				Toast.makeText(getActivity(), "manager", 1).show();
				flag_id= true;
			}
			break;
		default:
			break;
		}
		
	}

	
	
}
